﻿@typeparam TItem
@inherits BaseAutocomplete<TItem>
<Dropdown @ref="dropdownRef" @ref:suppressField>
    <TextEdit Text="@SelectedText" TextChanged="@HandleTextChanged" Placeholder="@Placeholder" Size="@Size" IsDisabled="@IsDisabled" KeyDown="@HandleTextKeyDown" />
    <DropdownMenu>
        @if ( DropdownVisible )
        {
            for ( int i = 0; i < FilteredData.Count; ++i )
            {
                var item = FilteredData[i];

                var text = TextField?.Invoke( item );
                var value = ValueField?.Invoke( item );

                <DropdownItem IsActive="@(i == ActiveItemIndex)" Value="@value" Clicked="@HandleDropdownItemClicked">@text</DropdownItem>
            }
        }
    </DropdownMenu>
</Dropdown>
